<template>
  <div></div>
</template>

<script>
  export default {
    name: 'pageTransit',
    data() {
      return {
        pageParam: {},
      };
    },
    methods: {
      init() {
        const { pageParam } = this;
        const { pageTransitTo } = pageParam;
        const pageConfig = {
          deviceDetail: {
            path: '/pages/device-detail/deviceDetail',
          },
        };
        const currentConfig = pageConfig[ pageTransitTo ] || {};
        let path = currentConfig.path;
        if (path) {
          const paramList = [];
          Object.keys(pageParam).forEach((val) => {
            if (val !== 'pageTransitTo') {
              paramList.push(`${val}=${pageParam[ val ]}`);
            }
          });
          if (paramList.length > 0) {
            path += `?${paramList.join('&')}`;
          }
          uni.reLaunch({
            url: path,
          });
        }
      },
    },
    onLoad(param) {
      this.pageParam = param;
      this.init();
    },
  };
</script>

<style scoped>

</style>
